﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TodoApp.GoodsModel;
using TodoApp.LiveShopGoodsDTO;
using Volo.Abp.Domain.Repositories;

namespace TodoApp
{
    /// <summary>
    ///  商品 统一规范 实现 服务 接口 
    /// </summary>
    public class LiveShopGoodsService : Volo.Abp.Application.Services.ApplicationService, ILiveShopGoodsService
    {
        private readonly IRepository<LiveShopGoods, int> _liveShopGoods;
        public LiveShopGoodsService(IRepository<LiveShopGoods, int> db ) {
            _liveShopGoods = db;
        }

        public async Task DeleteAsync(int id)
        {
            await _liveShopGoods.DeleteAsync(id);
        }

        public async Task<List<LiveShopGoodsShowDTO>> GetLIstAsync()
        {
          return  ObjectMapper.Map<List<LiveShopGoods>, List<LiveShopGoodsShowDTO>>(await _liveShopGoods.GetListAsync());
        }

        public async Task<string> InsertAsync(LiveShopGoodsAddDTO model)
        {
            await _liveShopGoods.InsertAsync(ObjectMapper.Map<LiveShopGoodsAddDTO, LiveShopGoods>(model));
            return "添加成功";
        }
    }
}
